let str = "nanfeng" // string类型

// 字面量类型
const str1: "nanfeng" = "nanfeng" //nanfeng类型
let age: 18 = 18;

// 游戏的方向 上下左右
function changeDirection(direction: "up" | "down" | "left" | "right") {
    console.log(direction)
}
changeDirection("down")

// 定义枚举 有值默认为0,递增
enum Direction { up, down, left, right }
function changedDirection(direction: Direction) {
    console.log(direction)
}
changedDirection(Direction.right) // 3  返回值是索引

// 设置枚举值
enum test { up = 10, down, left, right }
enum test1 { up = 13, down = 14, left = 15, right = 16 }
enum test2 { up = 2, down = 4, left = 6, right = 8 }

// 字符串枚举
enum Direction1 { up = "up", down = "down", left = "left", right = "right" }
function changedDirection1(direction: Direction1) {
    console.log(direction)
}
changedDirection1(Direction1.right) // "right"  返回值是right







